package com.lagou.dao.impl;

import java.util.ArrayList;
import java.util.List;

import javax.sql.rowset.CachedRowSet;

import com.lagou.dao.FirstDao;
import com.lagou.entity.First;
import com.lagou.util.JDBCUtil2;

public class FirstDaoImpl implements FirstDao{
	JDBCUtil2 util=JDBCUtil2.getInit();	
	public List<First> queryAll() {
		List<First> list=new ArrayList<First>();
		String sql="select * from t_first";
		CachedRowSet rs=util.query(sql);
		try {
			while(rs.next()) {
				First f=new First();
				f.setFid(rs.getInt("fid"));
				f.setfType(rs.getString("ftype"));
				list.add(f);
			}
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			util.closeCacheRowSet(rs);
		}
		return list;
	}
//	@Override
//	public First queryById(int fid) {
//		String sql="select * from t_first where fid=?";
//		CachedRowSet rs = util.query(sql,fid);
//		try {
//			if(rs.next()) {
//				return new First(rs.getInt("fid"),rs.getString("fname"));
//			}
//		}catch (Exception e) {
//				e.printStackTrace();
//			}finally {
//				util.closeCacheRowSet(rs);
//			}
//		return null;
//	}
//	@Override
	public List<Integer> queryFid() {
		List<Integer> list = new ArrayList<Integer>();
		String sql="select fid from t_first";
		CachedRowSet rs=util.query(sql);
		try {
			while(rs.next()) {
				int a=new Integer(rs.getInt("fid"));
				list.add(a);
			}
			
		} catch(Exception e) {
			e.printStackTrace();
		}finally {
			util.closeCacheRowSet(rs);
		}
		return list;
	}
	
}
